#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/cpu.h>
#include <linux/sched.h>
#include <linux/sched/task.h>
#include <linux/sched/init.h>
#include <linux/smp.h>
#include <linux/irqflags.h>

#include <linux/delay.h>

static long stack_ki[THREAD_SIZE / sizeof(long)];
static struct task_struct task_kinit = {
};

__weak void run_user(void)
{
}

__init static void kernel_init_freeable(void)
{
    smp_init();
}

static int kernel_init(void *unused)
{
    kernel_init_freeable();

    call_late_init();
    run_user();

    while (1)
    {
        msleep(2000);
    }

    return 0;
}

void kernel_init_startup(void)
{
    kernel_thread_init(&task_kinit, stack_ki, kernel_init, NULL, "kinit", 0);
}
